﻿@inherits EditDrawerBase<EmailServerConfigDto, Guid>
@if (_editModel != null)
{

    <Form Loading="@_isLoading"
            Model="@_editModel"
            LabelCol="new ColLayoutParam { Span = 8 }"
            WrapperCol="new ColLayoutParam { Span = 16 }"
            OnFinish="OnFormFinish"
            Context="model">
        <FormItem>
            <Input @bind-Value="@model.Name" />
        </FormItem>
        <FormItem>
            <Input @bind-Value="@model.Host" />
        </FormItem>
        <FormItem>
            <Input @bind-Value="@model.Port" />
        </FormItem>
        <FormItem>
            <Input @bind-Value="@model.FromEmail" />
        </FormItem>
        <FormItem>
            <Input @bind-Value="@model.AccountName" />
        </FormItem>
        <FormItem>
            <Input @bind-Value="@model.AccountPassword" Type="password" />
        </FormItem>
        <FormItem>
            <TextArea AutoSize="true" MinRows="2" MaxRows="6" @bind-Value="@model.Remark"></TextArea>
        </FormItem>
        <FormItem>
            <Input @bind-Value="@model.Tags" Type="hidden" />
            <SimpleSelect Mode="multiple" @bind-Values="@_tags">
                <SelectOptions>
                    @foreach (var gitem in EnumHelper.EnumToDictionary<EmailServerTag>())
                    {
                        <SimpleSelectOption Value="@(gitem.Key.ToString())" Label="@gitem.Value"></SimpleSelectOption>
                    }
                </SelectOptions>
            </SimpleSelect>
        </FormItem>
        <FormItem>
            <Switch @bind-Value="@model.EnableSsl"></Switch>
        </FormItem>
        <FormItem>
            <Switch @bind-Value="@model.IsLocked"></Switch>
        </FormItem>
        @if (this.Options.Type.Equals(DrawerInputType.Edit) || this.Options.Type.Equals(DrawerInputType.Select))
        {
            <FormItem Label="创建时间">
                <span>@model.CreatedTime.ToString(ClientConstant.DateTimeFormat)</span>
            </FormItem>
            <FormItem Label="更新时间">
                <span>@model.UpdatedTime?.ToString(ClientConstant.DateTimeFormat)</span>
            </FormItem>
        }
        <FormItem WrapperColOffset="8" WrapperColSpan="16">
            <Space>
                @if (!DrawerInputType.Select.Equals(this.Options.Type))
                {
                    <SpaceItem>
                        <Button Type="@ButtonType.Primary" HtmlType="submit">
                            @localizer["保存"]
                        </Button>
                    </SpaceItem>
                }
                <SpaceItem>
                    <Button OnClick="_=>OnFormCancel()">
                        @localizer["取消"]
                    </Button>
                </SpaceItem>
            </Space>
        </FormItem>
    </Form>
}
